package com.jkt.rms.commons.utils;

import org.apache.log4j.Logger;
/**
 * This class is implementation of all RMS Exception
 * 
 * @author JKT
 * @version 0.2
 */
public class RMSException extends Exception{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Logger LOG = Logger.getLogger(RMSException.class);
	private String businessReason = null;
	private String businessCode = null;

	public RMSException(Throwable cause, Object... args) {
		super(cause);
		checkForThrowables(getClass().getSimpleName(), args);
	}
	
	public RMSException(String businessCode) {
		this.businessCode = businessCode;
		
	}

	public RMSException(String businessCode, String businessReason) {
		this(businessCode);
		this.businessReason = businessReason;
	}

	static void checkForThrowables( String className, Object... args ) {
        if (args != null && args.length > 0) {
            if (args[0] instanceof Throwable) {
                final IllegalArgumentException e = new IllegalArgumentException( className
                        + " constructor: potential coding error: first is a Throwable." );
                LOG.error( "", e );
                return;
            }
        }
    }
	
	public String getBusinessReason() {
		return businessReason;
	}

	public void setBusinessReason(String businessReason) {
		this.businessReason = businessReason;
	}

	public String getBusinessCode() {
		return businessCode;
	}

	public void setBusinessCode(String businessCode) {
		this.businessCode = businessCode;
	}


}
